package com.henry.javastudy.c04;

import java.util.concurrent.Semaphore;
import java.util.concurrent.locks.ReentrantLock;

public class MyRunnable4 implements Runnable {
    private int result=0;
    ReentrantLock reentrantLock ;
    public MyRunnable4(ReentrantLock reentrantLock)
    {
        this.reentrantLock=reentrantLock;

    }
    @Override
    public void run() {
        try
        {
            reentrantLock.lock();
            setResult(MyCanculate.sum());

        }
        catch (Exception e){}
        finally {
            reentrantLock.unlock();
        }
    }
    public void setResult(Integer i){
        result=i;
    }
    public int getResult()
    {
        return result;
    }
}
